<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item" style="display: none">
        <label class="layui-form-label required">ID</label>
        <div class="layui-input-block">
            <input type="number" id="id" name="id" lay-verify="required"  class="layui-input">
            <!--            lay-reqtext="手机不能为空" placeholder="请输入手机"-->
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-block">
            <input type="text" id="username" name="username" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名"   class="layui-input">
            <!--            lay-reqtext="手机不能为空" placeholder="请输入手机"-->
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">密码</label>
        <div class="layui-input-block">
            <input type="text" id="password" name="password" lay-verify="required" lay-reqtext="密码不能为空" placeholder="请输入密码" value="" class="layui-input">

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户类型</label>
        <div class="layui-input-block" >
            <input type="radio" name="role"  value="1" title="普通用户" checked="">
            <input type="radio" name="role"  value="2" title="管理员">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户状态</label>
        <div class="layui-input-block">
            <input type="radio" name="aaccountState" value="0" title="锁定状态" checked="">
            <input type="radio" name="aaccountState" value="1" title="正常状态">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">电话</label>
        <div class="layui-input-block">
            <input type="text" id="tel" name="tel" lay-verify="required" lay-reqtext="电话不能为空" placeholder="请输入电话" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">课题组名</label>
        <div class="layui-input-block">
            <input type="text" id="teamName" name="teamName" placeholder="请输入密码" value="" lay-reqtext="密码不能为空" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-block">
            <input type="text" id="realName" name="realName" placeholder="请输入手机号" value="" lay-reqtext="手机不能为空" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" id="email" name="email"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">省份</label>
        <div class="layui-input-block">
            <input type="text" id="addressProvince" name="addressProvince"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">城市</label>
        <div class="layui-input-block">
            <input type="text" id="addressCity" name="addressCity"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">区域</label>
        <div class="layui-input-block">
            <input type="text" id="addressDistrict" name="addressDistrict"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">详细地址</label>
        <div class="layui-input-block">
            <input type="text" id="addressDetail" name="addressDetail"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" id="mark" name="mark"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">头像名</label>
        <div class="layui-input-block">
            <input type="text" id="headImgName" name="headImgName"  class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="../../lib/layui-v/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            // var index = layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            var index =  layer.confirm('真的修改么',{icon:3, title:'提示信息'},
                function () {
                    $.ajax({
                        url: '/tTeams/update',
                        data: JSON.stringify(data.field),
                        contentType: "application/json;charset=utf-8",
                        dataType:'json',
                        type: "post",
                        async: false,//false为同步，这个Ajax请求将整个浏览器锁死
                        success:function (d){
                            if (d.msg==1){
                                window.parent.location.reload();//修改成功后刷新父界面
                            }else {
                                layer.msg("修改失败", {icon: 5});
                            }
                        }
                    })

                    // 关闭弹出层
                    layer.close(index);

                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);

                });

            return false;
        });

    });
</script>
</body>
</html>